package com.vecspace.utils.log;

/**用于Request执行过程中的日志记录
 * 
 * @version: 1.0
 * @author: wanghua
 */
public class HttpRequestLogThreadLocal{
	private static ThreadLocal<HttpRequestLog> threadLocal = new ThreadLocal<HttpRequestLog>();

	private static ThreadLocal<HttpRequestLog> getHttpRequestLogThreadLocal() {
		if(threadLocal.get() == null){
			HttpRequestLog info = new HttpRequestLog();
			threadLocal.set(info);
		}
		return threadLocal;
	}
 
	/**用于清除线程变量（在有线程池的情况下，必须先remove之后再使用）
	 * 
	 *  
	 * @author: wanghua
	 */
	public static void remove() {
		if(threadLocal != null) {
			threadLocal.remove();
		}
	}
	/**
	 * 
	 * @return 
	 * @author: wanghua
	 */
	public static HttpRequestLog getHttpRequestLogContext(){
		return getHttpRequestLogThreadLocal().get();
	}
}
